<template>
  <div class="singer_wrap">
    <div class="title">搜索 艺人 "{{ keyword }}"</div>
    <div class="item_wrap">
      <div v-for="(item, index) in singerList" :key="index" class="item">
        <div class="cover">
          <el-image
            lazy
            @click="toDetail(item.id)"
            :src="item.img1v1Url"
            fit="cover"
          ></el-image>
        </div>
        <div class="name">{{ item.name }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getSearchList } from "@/util/findMusic.js";
export default {
  name: "Searchsinger",

  data() {
    return {
      keyword: this.$route.params.keyword,
      singerList: [],
    };
  },

  created() {
    this.getSearchList();
  },

  methods: {
    //获取搜素歌手
    async getSearchList() {
      let {
        data: {
          result: { artists },
        },
      } = await getSearchList(this.$route.params.keyword, 20, 0, 100);
      //   console.log(artists)
      if (artists) {
        this.singerList = artists;
      }
    },
    //跳转至歌手详情
    toDetail(id) {
      this.$router.push("/singerInfo/" + id);
    },
  },
};
</script>

<style lang="less" scoped>
.singer_wrap {
  padding: 1rem 8rem;
  margin-top: 20px;
//   width: 100%;
  height: 100%;
  .title{
      margin-bottom: 40px;
      font-size: 30px;
      font-weight: 600;
  }
  .item_wrap {
    display: grid;
    justify-content: space-around;
    grid-template-columns: repeat(auto-fill, 16rem);
  }
  .item {
      margin-bottom: 3rem;

    .cover {
      width: 15.375rem;
      height: 15.375rem;
      .el-image {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }
    .name {
      text-align: center;
      font-size: 18px;
      font-weight: 600;
      margin-top: 10px;
    }
  }
}
</style>